package com.hzhc.controller.dispatch;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hzhc.annotation.SysTemLog;
import com.hzhc.common.BaseController;
import com.hzhc.dto.UserDto;
import com.hzhc.entity.CntrInfo;
import com.hzhc.enumBean.LoginUserType;
import com.hzhc.enumBean.ResultUtilCodeEnum;
import com.hzhc.service.CancelSendTransportService;
import com.hzhc.utils.ResultUtil;
import com.hzhc.utils.TokenUtil;
import com.hzhc.vo.CancelSendTransportVo;
import lombok.RequiredArgsConstructor;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * <p>
 * 取消发运 前端控制器
 * </p>
 *
 * @author shizj
 * @since 2024-09-02
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/cancelSendTransport")
public class CancelSendTransportController extends BaseController {
    private final CancelSendTransportService cancelSendTransportService;

    /**
     * 取消发运列表
     */
    @RequestMapping("/getList")
    @ResponseBody
    public ResultUtil<List<CancelSendTransportVo>> getList(HttpServletRequest request, @RequestBody CancelSendTransportVo vo){
        Page<CancelSendTransportVo> page = new Page<>(vo.getPageIndex(),vo.getPageSize());
        List<CancelSendTransportVo> list = cancelSendTransportService.getList(page,vo);
        return ResultUtil.build(list,page.getTotal(),page.getPages(), ResultUtilCodeEnum.SUCCESS);
    }

    /**
     * 在场箱查询取消发运新增
     */
    @PostMapping("/addCancelSendTransport")
    @SysTemLog(operModul = "调度管理-在场箱查询",operType = "ADD",operDesc = "取消发运添加",modular="PC")
    public ResultUtil<T> addCancelSendTransport(HttpServletRequest request, @RequestBody CntrInfo info){
        UserDto user = TokenUtil.getUser(request);
        return cancelSendTransportService.addCancelSendTransport(user,info, LoginUserType.USER.getCode());
    }

    /**
     * 审核
     */
    @PostMapping("/updateCheck")
    @SysTemLog(operModul = "调度管理-取消发运", operType = "CHECK", operDesc = "取消发运审核", modular = "APP")
    public ResultUtil<T> updateCheck(HttpServletRequest request, @RequestBody CancelSendTransportVo vo) {
        UserDto user = TokenUtil.getUser(request);
        return cancelSendTransportService.updateCheck(user,vo);
    }

    /**
     * 驳回
     */
    @PostMapping("/updateRefugee")
    @SysTemLog(operModul = "调度管理-取消发运", operType = "REFUGEE", operDesc = "取消发运驳回", modular = "APP")
    public ResultUtil<T> updateRefugee(HttpServletRequest request, @RequestBody CancelSendTransportVo vo) {
        UserDto user = TokenUtil.getUser(request);
        return cancelSendTransportService.updateRefugee(user,vo);
    }
}
